<?php

namespace app\admin\controller;

use think\Controller;
use think\Db;
use app\common\service\SysLogService;

class Extractfiltering extends Controller
{
    public function index()
    {

        $data = Db::table('zstp_extract_filtering')->find();

        $txt = $data['txt'];

        $txtArr = json_decode($txt, true);

        return json([
            'code' => 200,
            'data' => $txtArr,
            'message' => '获取成功'
        ]);


      
    }

    public function save()
    {
        $data = request()->post();

       
        Db::table('zstp_extract_filtering')->where('id', 1)->update(['txt' => json_encode($data)]);

        $sysLogService = new SysLogService();

        $sysLogService->addLog('抽取内容过滤规则', 1, 2, '更新内容:'.json_encode($data));
        
        return json([
            'code' => 200,
            'message' => '保存成功'
        ]);
        
    }


}